let arr=["item1","item2","item3","item4","item5"];

let arr1=[
    {
        content:"section1",
        index:0
    },
    {
        content:"section2",
        index:2
    },
]




// function works(arr,arr1){
//   arr1.forEach((item,index)=>{
//       console.log(item)
//       arr.splice(item.index+index,0,item.content);
//   })
//   return arr;
// }
// console.log(works(arr,arr1));


work=(arr,arr1)=>{
    arr1.forEach((item,index)=>{
       arr[item.index]=[item.content,arr[item.index]];
    })
    return arr.flat(arr.length);
}

console.log(work(arr,arr1));
